using System;
using System.IO;
using AdaNNTP;
using System.Xml;
using System.ServiceModel;
using Ada.Protocol;
using System.ServiceModel.Description;
	
namespace Ada
{
	class MainClass
	{
        //public static Uri URI = new Uri("http://localhost:8192/ada");

        internal AdaNNTP.NewsgroupService newsgroupService;
		
		public static void Main (string[] args)
		{
            ServiceHost wcfHost = new ServiceHost(typeof(ServerManagerHost));
			try
			{
                //The Config class has validation integrated
				Config.Instance.LoadConfig(args[0]);
			}
			catch (Exception ex)
			{
				Console.WriteLine("AdaNZB.UI: Main: " + ex.ToString());
				Config.Instance.LoadConfig(null);
			}

            

            try
            {
                wcfHost.AddServiceEndpoint(typeof(IServerManager), new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport), "ServerManager");
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                
                wcfHost.Description.Behaviors.Add(smb);
                wcfHost.Open();
                Console.WriteLine("AdaNZB.UI: Main: WCF Service Hosting started.");

            }
            catch (Exception ex)
            {
                Console.WriteLine("AdaNZB.UI: Main: " + ex.ToString());
            }


            Console.ReadLine();
		}
		
		
	}
}

